/*
 * main.cpp
 *
 *  Created on: Oct 11, 2015
 *      Author: rpi
 */

#include <iostream>
#include <cstdio>
#include <cstdlib>

#include "json/json.h"
#include "jsonrpc.h"

#include "RpcClient.h"

#ifdef __cplusplus
extern "C"
{
#endif
void initTimeTick();
#ifdef __cplusplus
}
#endif

static void initNetworking()
{
	if(!networking::init())
	{
	  std::cerr << "Networking initialization failed" << std::endl;
	  exit(EXIT_FAILURE);
	}
}

static void finaNetworking()
{
	networking::cleanup();
}

int main(int argc, char **argv)
{
	/* avoid compilation warnings */
	(void)argc;
	(void)argv;

	//initTimeTick();
	initNetworking();
	RpcClient rpcClient("127.0.0.1", 8086);

	Json::Value joResp;
	if (rpcClient.request("getDeviceList", joResp) == false)
	{
		std::cout << "GetDeviceList: response failed" << std::endl;
		exit(EXIT_FAILURE);
	}

	if (rpcClient.request("getInstanceList", joResp) == false)
	{
		std::cout << "GetInstanceList: response failed" << std::endl;
		exit(EXIT_FAILURE);
	}

	finaNetworking();
}

